import { reactive } from "vue";

export const store = reactive({
    luckySecret: '',
    updateSecret(s) {
        this.luckySecret = s
    },
    /**
     * [{ amount:188, token: 'Ji8身体健康' }]
     */
    luckyTokens:[],
    updateToken(arr) {
        this.luckyTokens = arr
    },
    updateTokenByIndex(index,value) {
        console.log(`store.luckyTokens updated:index ${index}`)
        console.log(`store.luckyTokens updated:value:${value}`)

        this.luckyTokens[index] = value
        console.log(`store.luckyTokens updated: ${JSON.stringify(store.luckyTokens)}`)
    },

    /*当前关卡*/
    // step: 1,
    step: 0,
    forward() {
        console.log(this.step)
        this.step++
    },
    backward() {
        this.step--
    },

    /*剩余抽奖次数*/
    lotteryTimes: 0,
    addTimes(n) {
        this.lotteryTimes += n
        console.log(`add ${n} times, final:${this.lotteryTimes}`)
    },
    reduceTimes(n) {

        this.lotteryTimes = this.lotteryTimes - n >=0 ? this.lotteryTimes - n : 0;

        console.log(`reduce ${n} times, final:${this.lotteryTimes}`)
    },

    /*中奖的卡牌下标*/
    hits: [
        false,false,false,
        false,false,false,
        false,false,false
    ],
    hitCard(index) {
        console.log(`real hit ${index}`)
        this.hits[index] = true
    }
})